<%@ page import="com.touzi.constants.MobileCons" %>
<%@ page import="com.touzi.utils.MyHTTPUtils" %>
<%@ page import="org.apache.ibatis.session.SqlSession" %>
<%@ page import="com.touzi.constants.DbCons" %>
<%@ page import="com.touzi.mapper.UserMapper" %>
<%@ page import="org.apache.ibatis.session.SqlSessionFactory" %>
<%@ page import="com.touzi.beans.dbs.users.User" %>
<%@ page import="com.touzi.mapper.SysconfigMapper" %><%--
  Created by IntelliJ IDEA.
  User: w7851
  Date: 2018/5/16
  Time: 7:49
  分享功能页面
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<%
    User user = null;
    String shareurl = null;
    try {
        Cookie usercookie = MyHTTPUtils.getCookieByName(request, MobileCons.COOKIE_USERNAME);
        String userphone = usercookie.getValue();
        SqlSession sqlSession = ((SqlSessionFactory) application.getAttribute(DbCons.DB_FACTORY)).openSession();
        UserMapper userMapper = sqlSession.getMapper(UserMapper.class);
        SysconfigMapper sysconfigMapper = sqlSession.getMapper(SysconfigMapper.class);
        String BASE_URL = sysconfigMapper.getBaseURL();
        user = userMapper.findUserByDhmw(userphone).get(0);
        request.setAttribute("user", user);
        shareurl = BASE_URL + "/mobile/regnew.jsp?recoid=" + user.id;

        sqlSession.close();
    } catch (Exception e) {
        e.printStackTrace();
        response.sendRedirect("/mobile");
        return;
    }
%>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>分享和邀请</title>
    <meta content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0" name="viewport"/>

    <meta content="yes" name="apple-mobile-web-app-capable"/>
    <meta content="black" name="apple-mobile-web-app-status-bar-style"/>
    <meta content="telephone=no" name="format-detection"/>

    <link rel="stylesheet" href="/css/ydui.css">
    <script src="/js/ydui.flexible.js"></script>
    <style>
        .xuanzed {
            color: #E8574E;
        }
    </style>
</head>
<body>
<div class="g-flexview">
    <header class="m-navbar  navbar-fixed">
        <div class="navbar-center"><span class="navbar-title">分享和邀请</span></div>
    </header>


    <div class="g-scrollview" style="margin-top: 1rem;margin-bottom: 1rem;padding: 16px">

        <p>你的邀请链接: <%=shareurl%>
        </p>
        <img src="/mobile/inviteimage.jsp?inviteid=<%=user.id%>" style="width: 100%;height: auto">

    </div>

    <footer class="m-tabbar tabbar-fixed">
        <a href="/mobile?method=gomobilepage&page=index" class="tabbar-item">
        <span class="tabbar-icon">
           <i class="icon-home"></i>
        </span>
            <span class="tabbar-txt">首页</span>
        </a>

        <a href="/mobile?method=gomobilepage&page=my" class="tabbar-item">
        <span class="tabbar-icon">
            <i class="icon-ucenter-outline"></i>
        </span>
            <span class="tabbar-txt">我的</span>
        </a>

        <a href="javascript:void(0)" class="tabbar-item">
        <span class="tabbar-icon">
            <i class="icon-share1 xuanzed"></i>
        </span>
            <span class="tabbar-txt xuanzed">邀请</span>
        </a>
    </footer>
</div>
</body>
<script>

</script>
</html>
